home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / Install / program files / Borland / BDS / 3.0 / Demos / CSharp / Applications / Temp Converter / Celsius42.cs < prev    next >
Encoding:
Text File  |  2004-10-22  |  606 b   |  29 lines

  1. ∩╗┐using System;
  2.  
  3. namespace Celsius
  4. {
  5.     /// <summary>
  6.     /// Summary description for Celsius42.
  7.     /// </summary>
  8.     public class Celsius42
  9.     {
  10.         public Celsius42()
  11.         {
  12.         }
  13.         const double AbsoluteZero = -237.15;
  14.  
  15.         public double Celsius2Fahrenheit(double Degrees)
  16.         {
  17.             if (Degrees < AbsoluteZero)
  18.                 throw new ApplicationException("Invalid Temperature");
  19.             return 32 + (9 * Degrees / 5);
  20.         }
  21.         public double Fahrenheit2Celsius(double Degrees)
  22.         {
  23.             if (Degrees < AbsoluteZero)
  24.                 throw new ApplicationException("Invalid Temperature");
  25.             return (5 * (Degrees - 32) / 9);
  26.         }
  27.     }
  28. }
  29.